home *** CD-ROM | disk | FTP | other *** search
- /*
- * pccde.c
- *
- * Practical Algorithms for Image Analysis
- *
- * Copyright (c) 1997, 1998, 1999 MLMSoftwareGroup, LLC
- */
-
- /* PCCDE: program decodes primitives chain code (PCC) from file
- * and writes output image
- * usage: pccde infile.pcc outfile.img
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <tiffimage.h> /* tiff file format info */
- #include <images.h> /* images information file */
- #include "pcc2.h" /* header file for PCC programs */
- extern void print_sos_lic ();
-
- unsigned char *fcCode; /* code storage */
- long nByteCode; /* no. bytes in storage */
-
- int input (int, char **);
- int usage (short);
-
- main (argc, argv)
- int argc;
- char *argv[];
- {
- Image *imgO; /* output image structure */
- unsigned char **image; /* image array */
- long widthO, heightO; /* output image size */
-
- if ((input (argc, argv)) < 0)
- return (-1);
-
- /* open input PCC file */
- if (pccread (argv[1], &fcCode, &nByteCode, &widthO, &heightO) == -1)
- exit (1);
- printf ("image size: %dx%d, PCC length = %d\n",
- widthO, heightO, nByteCode);
-
- /* allocate output image */
- imgO = ImageAlloc (heightO, widthO, 8);
- image = ImageGetPtr (imgO);
-
- /* construct tables of feature chain decodes */
- pccdecodes ();
-
- /* perform feature chain decoding */
- printf ("decoding being performed\n");
- pccdecode (image, widthO, heightO, 0);
-
- /* write image output file */
- printf ("output image being written\n");
- ImageOut (argv[2], imgO);
-
- return (0);
- }
-
-
- /* USAGE: function gives instructions on usage of program
- * usage: usage (flag)
- * When flag is 1, the long message is given, 0 gives short.
- */
-
- usage (flag)
- short flag; /* flag =1 for long message; =0 for short message */
- {
-
- /* print short usage message or long */
- printf ("USAGE: pccde infile outimg [-L]\n");
- if (flag == 0)
- return (-1);
-
- printf ("\npccde decodes Primitives Chain Code (PCC)\n");
- printf ("in input file to output image.\n\n");
- printf ("ARGUMENTS:\n");
- printf (" infile: input file containing PCC (BINARY)\n");
- printf (" outimg: output image filename (TIF)\n\n");
- printf ("OPTIONS:\n");
- printf (" -L: print Software License for this module\n");
-
- return (-1);
- }
-
-
- /* INPUT: function reads input parameters
- * usage: input (argc, argv)
- */
-
- #define USAGE_EXIT(VALUE) {usage (VALUE); return (-1);}
-
- input (argc, argv)
- int argc;
- char *argv[];
- {
-
- if (argc == 1)
- USAGE_EXIT (1);
- if (argc == 2)
- USAGE_EXIT (0);
- if (argc == 4 && strcmp (argv[3], "-L") == 0) {
- print_sos_lic ();
- exit (0);
- }
-
- return (0);
- }
-